/*
-----------------------------------------------------------------------------
This file is part of escog.

Copyright (c) 2009 Jacob Essex

escog is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

escog is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with escog.  If not, see <http://www.gnu.org/licenses/>.
-----------------------------------------------------------------------------
*/

#include "settings.h"

Settings* Settings::mInstance = 0;

Settings::Settings(){
    if ( mInstance != 0 )
        assert(0);
    mInstance = this;

    std::ifstream ifs("settings.gc");
    if ( ifs.is_open() ){
        boost::archive::text_iarchive ia(ifs);
        ia >> *this;
    }
}

Settings::~Settings(){
    std::ofstream ofs("settings.gc");
    boost::archive::text_oarchive oa(ofs);
    oa << *this;
}

std::string Settings::get(const std::string& k) const{
    std::map<std::string,std::string>::const_iterator i = mMap.find(k);
    if ( i == mMap.end() )
        return "";
    return i->second;
}



